addOnCallbackListener

Adds a listener to be notified of callbacks from the loaded gadget.

Callbacks are events or data sent from the gadget's JavaScript environment back to the native Android application. These are typically initiated by the gadget calling methods on the JavascriptInterfaceObject (exposed as window.Client or a similar name in the gadget's JavaScript context). The JavascriptInterfaceObject then uses a Handler to relay these callbacks to the main thread, where listeners registered via this method are invoked.

Multiple listeners can be added. Each listener will receive all callbacks. Listeners are stored in a thread-safe list (CopyOnWriteArrayList), allowing for safe addition and removal even from different threads, although notification will occur on the main thread.

Parameters

listener

The OnCallbackListener to add. Must not be null. If a null listener is provided, the method does nothing.

See also